#include <stdio.h>
#include <stdlib.h>
#pragma once;
typedef char QueueData;
typedef struct Element
{
	QueueData data;
	struct Element * next;
}Element;
typedef struct Queue
{
	Element*front;
	Element*rear;
	int size;
}Queue;
Element* CreatEle(QueueData data)
{
	Element *node = (Element *)malloc(sizeof(Element));
	node->data = data;
	node->next = NULL;
	return node;
}
void QueueInit(Queue *queue)
{
	queue->front = queue->rear = NULL;
	queue->size = 0;
}
void PushQueue(Queue*queue,QueueData data)
{
	Element *newNode = CreatEle(data);
	if (queue->size == 0)
	{
		queue->rear = newNode;
		queue->front = newNode;
	}
	else
	{
		queue->rear->next = newNode;
		queue->rear = newNode;
	}
	queue->size += 1;
}
void Pop(Queue *queue)
{
	if (queue->size <= 0)
		return;
	Element * temp = queue->front;
	if (queue->size == 1){
		queue->front = queue->rear = NULL;
	}
	else
		queue->front = queue->front->next;
	free(temp);
	queue->size--;
	temp = NULL;
}
QueueData PopQueue(Queue *queue)
{
	if (queue->size <= 0)
		return NULL;
	QueueData data = queue->front->data;
	Pop(queue);
	return data;
}
bool IsEmpty(Queue*queue)
{
	return queue->size == 0 ? true:false;
}